
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
  <meta charset="utf-8">
  <title>ksnowlv</title>
  <meta name="author" content="律威">

  
  <meta name="description" content="我们通过localhost访问php页面，如何使用自定义域名服务在本地生效呢？ 1.修改nginx配置文件。 文件位置:/usr/local/etc/nginx/nginx.conf,内容如下: server { listen 80; #域名服务支持 server_name ksnowlv.com &hellip;">
  

  <!-- http://t.co/dKP3o1e -->
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  
  <link rel="canonical" href="http://ksnowlv.github.io/blog/page/9">
  <link href="/favicon.png" rel="icon">
  <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
  <link href="/atom.xml" rel="alternate" title="ksnowlv" type="application/atom+xml">
  <script src="/javascripts/modernizr-2.0.js"></script>
  <script src="//ajax.useso.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script>!window.jQuery && document.write(unescape('%3Cscript src="./javascripts/lib/jquery.min.js"%3E%3C/script%3E'))</script>
  <script src="/javascripts/octopress.js" type="text/javascript"></script>
  <!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.useso.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.useso.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">

  
  <script type="text/javascript">
    var _gaq = _gaq || [];
     _gaq.push(['_setAccount', 'UA-39546615-2']);
    // _gaq.push(['_trackPageview']);

    // (function() {
    //   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    //   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    //   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    // })();

    _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src='http://droidyue-tools.qiniudn.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
  </script>


</head>

<body   >
  <header role="banner"><hgroup>
  <h1><a href="/">ksnowlv</a></h1>
  
    <h2>回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.</h2>
  
</hgroup>

</header>
  <nav role="navigation"><ul class="subscription" data-subscription="rss">
  <li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
  
</ul>
  
<form action="http://google.com/search" method="get">
  <fieldset role="search">
    <input type="hidden" name="q" value="site:ksnowlv.github.io" />
    <input class="search" type="text" name="q" results="0" placeholder="Search"/>
  </fieldset>
</form>
  
<ul class="main-navigation">
  <li><a href="/">博客首页</a></li>
  <li><a href="/blog/archives">文章列表</a></li>
  <!-- <li><a href="/about-me">关于我</a></li>
 -->
</ul>

</nav>
  <div id="main">
    <div id="content">
      <div class="blog-index">
  
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/21/mac-nginx-xia-codeigniteryu-ming-fu-wu-fang-wen/">Mac-nginx下codeigniter域名服务访问</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-21T11:35:00+08:00" pubdate data-updated="true">Aug 21<span>st</span>, 2014</time>
        
         | <a href="/blog/2014/08/21/mac-nginx-xia-codeigniteryu-ming-fu-wu-fang-wen/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>我们通过localhost访问php页面，如何使用自定义域名服务在本地生效呢？</p>

<h4>1.修改nginx配置文件。</h4>

<p>文件位置:<code>/usr/local/etc/nginx/nginx.conf</code>,内容如下:</p>

<pre><code> server {
    listen       80;
    #域名服务支持
    server_name  ksnowlv.com www.ksnowlv.com;
    #目标目录
    root   /Users/ksnowlv/Movies/PHP/CodeIgniter;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }


     # set expiration of assets to MAX for caching
    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
            expires max;
            log_not_found off;
    }

    location / {
            # Check if a file or directory index file exists, else route it to index.php.
            try_files $uri $uri/ /index.php;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        #root           /Users/ksnowlv/Movies/PHP/CodeIgniter;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}
</code></pre>

<h4>2.添加ip和域名服务的绑定。</h4>

<p> 打开<code>etc</code>目录下的<code>hosts</code>文件,在文件末尾添加对域名服务的支持。</p>

<pre><code># Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost
#添加对域名服务www.ksnowlv.com的支持。
127.0.0.1    www.ksnowlv.com  
</code></pre>

<h4>3.修改codeigniter中php配置文件对域名服务的支持。</h4>

<p>编辑<code>Codeigiter/application/configconfig.php</code>文件。</p>

<p><strong>原有的</strong></p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$config[&#39;base_url&#39;]   = &quot;&quot;;</span>
</span><span class='line'>
</span><span class='line'><span class="x">$config[&#39;index_page&#39;]     = &quot;&quot;;</span>
</span><span class='line'>
</span><span class='line'><span class="x">$config[&#39;uri_protocol&#39;]   = &quot;AUTO&quot;</span>
</span></code></pre></td></tr></table></div></figure>


<p><strong>修改为</strong></p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$config[&#39;base_url&#39;]   = &#39;http://ksnowlv.com/&#39;;</span>
</span><span class='line'>
</span><span class='line'><span class="x">$config[&#39;index_page&#39;]     = &quot;&quot;;</span>
</span><span class='line'>
</span><span class='line'><span class="x">$config[&#39;uri_protocol&#39;]   = &#39;REQUEST_URI&#39;;</span>
</span></code></pre></td></tr></table></div></figure>


<h4>3.启动nginx和php服务。</h4>

<pre><code>#如果已启动过nginx服务，可以使用sudo nginx -s reload 来重启.
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo nginx
Password:
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo php-fpm
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$
</code></pre>

<p> 此时<code>nginx</code>和<code>php</code>服务启动完成。</p>

<h4>4.在浏览器打开<code>http://www.ksnowlv.com/index.php</code>，即可看到<code>Welcome to CodeIgniter!</code>欢迎页面。</h4>

<p><img src="/images/post/2014-08-21-mac-nginx-xia-codeigniteryu-ming-fu-wu-fang-wen/codeigniter_url_page.png" alt="image" /></p>

<p>至此，关于<code>CodeIgniter</code>的基本安装配置已经OK.下一步,直接投入实战吧!</p>

<p><strong>另外</strong>:和磊兄聊的时候,原来已经投身手机游戏开发,赞一个!</p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/21/mac-nginx-xia-codeigniterde-an-zhuang-pei-zhi/">Mac-nginx下CodeIgniter的安装配置</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-21T09:46:00+08:00" pubdate data-updated="true">Aug 21<span>st</span>, 2014</time>
        
         | <a href="/blog/2014/08/21/mac-nginx-xia-codeigniterde-an-zhuang-pei-zhi/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>   经过筛选对比,php开发框架，我选择了<a href="https://ellislab.com/codeigniter">CodeIgniter</a><code>2.2</code>版本。</p>

<h4>1.下载解压即可。其目录结构：</h4>

<p><img src="/images/post/2014-08-21-mac-nginx-xia-codeigniterde-an-zhuang-pei-zhi/codeigniter_dir.png" alt="image" /></p>

<p>详情参看相关开发文档</p>

<h4>2.修改nginx配置文件。</h4>

<p>在<code>/usr/local/etc/nginx</code>打开<code>nginx.conf</code>进行编辑。
主要修改点:<code>root</code>目录指向<code>codeigniter</code>目录.完整内容如下：</p>

<pre><code>server {
    listen       8080;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /Users/ksnowlv/Movies/PHP/CodeIgniter;
        index  index.html index.htm index.php;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /Users/ksnowlv/Movies/PHP/CodeIgniter;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
</code></pre>

<p>当时在这折腾了半天，试了不少坑爹的做法。</p>

<h4>3.启动nginx和php服务。</h4>

<pre><code>#如果已启动过nginx服务，可以使用sudo nginx -s reload 来重启.
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo nginx
Password:
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo php-fpm
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$
</code></pre>

<p> 此时<code>nginx</code>和<code>php</code>服务启动完成。</p>

<h4>4.在浏览器打开<code>http://localhost:8080/index.php</code>，即可看到<code>Welcome to CodeIgniter!</code>欢迎页面。</h4>

<p><img src="/images/post/2014-08-21-mac-nginx-xia-codeigniterde-an-zhuang-pei-zhi/codeigniter_page.png" alt="image" /></p>

<p><strong>其它</strong>:和凡兄聊的时候,原来已经身在大百度做智能交通,good luck!</p>

<p><strong>能做自己喜欢做的事，挺爽!</strong></p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/20/mac-xia-sha-si-zhan-yong-mou-ge-duan-kou-de-jin-cheng/">Mac下杀死占用某个端口的进程</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-20T19:20:00+08:00" pubdate data-updated="true">Aug 20<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/20/mac-xia-sha-si-zhan-yong-mou-ge-duan-kou-de-jin-cheng/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p><code>Mac</code>下启动<code>nginx</code>服务时，经常会遇见到端口被占用的情况。</p>

<p>如何杀死占用相应端口的进程呢？</p>

<h4>1.查看占用该端口的进程。</h4>

<p>格式:<strong>lsof -i:port</strong>   port:端口号</p>

<h4>2.杀死进程。</h4>

<p>格式:<strong>kill PID</strong>   PID:进程的PID</p>

<h4>3.示例</h4>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~$lsof -i:80
COMMAND    PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.apple  640 ksnowlv   13u  IPv4 0x5c463434d35d8295      0t0  TCP 10.68.187.236:56236-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   15u  IPv4 0x5c463434d3534295      0t0  TCP 10.68.187.236:56237-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   16u  IPv4 0x5c463434d3534295      0t0  TCP 10.68.187.236:56237-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   17u  IPv4 0x5c463434cb37aa7d      0t0  TCP 10.68.187.236:56239-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   19u  IPv4 0x5c463434cb369a7d      0t0  TCP 10.68.187.236:56238-&gt;202.102.85.61:http (ESTABLISHED)
com.apple  640 ksnowlv   20u  IPv4 0x5c463434d35d8295      0t0  TCP 10.68.187.236:56236-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   22u  IPv4 0x5c463434cb37aa7d      0t0  TCP 10.68.187.236:56239-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   24u  IPv4 0x5c463434cb369a7d      0t0  TCP 10.68.187.236:56238-&gt;202.102.85.61:http (ESTABLISHED)
com.apple  640 ksnowlv   26u  IPv4 0x5c463434cb369295      0t0  TCP 10.68.187.236:56242-&gt;103.245.222.134:http (ESTABLISHED)
com.apple  640 ksnowlv   28u  IPv4 0x5c463434d443b295      0t0  TCP 10.68.187.236:56241-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   30u  IPv4 0x5c463434d443b295      0t0  TCP 10.68.187.236:56241-&gt;117.79.146.98:http (ESTABLISHED)
com.apple  640 ksnowlv   31u  IPv4 0x5c463434cb369295      0t0  TCP 10.68.187.236:56242-&gt;103.245.222.134:http (ESTABLISHED)
AliWangwa 2170 ksnowlv   13u  IPv4 0x5c463434d35faa7d      0t0  TCP 10.68.187.236:56234-&gt;203.208.49.174:http (ESTABLISHED)
AliWangwa 2170 ksnowlv   15u  IPv4 0x5c463434d35faa7d      0t0  TCP 10.68.187.236:56234-&gt;203.208.49.174:http (ESTABLISHED)
ksnowlv@ksnowlvdeMacBook-Pro~$kill 2170
ksnowlv@ksnowlvdeMacBook-Pro~$kill 640
ksnowlv@ksnowlvdeMacBook-Pro~$lsof -i:80
ksnowlv@ksnowlvdeMacBook-Pro~$
</code></pre>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/19/ios-ji-he-lei-shen-kao-bei/">iOS集合类深拷贝</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-19T19:42:00+08:00" pubdate data-updated="true">Aug 19<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/19/ios-ji-he-lei-shen-kao-bei/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>iOS集合类默认是浅拷贝，那如何深拷贝呢？</p>

<h4>1.集合类的浅拷贝:</h4>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="n">NSMutableArray</span> <span class="o">*</span><span class="n">newNames</span> <span class="o">=</span>  <span class="p">[[</span><span class="n">NSMutableArray</span> <span class="n">alloc</span><span class="p">]</span> <span class="nl">initWithArray:</span><span class="n">names</span><span class="p">];</span>
</span></code></pre></td></tr></table></div></figure>


<h4>2.集合类的深拷贝:</h4>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="n">NSMutableArray</span> <span class="o">*</span><span class="n">newNames</span> <span class="o">=</span>  <span class="p">[[</span><span class="n">NSMutableArray</span> <span class="n">alloc</span><span class="p">]</span> <span class="nl">initWithArray:</span><span class="n">names</span> <span class="nl">copyItems:</span><span class="n">YES</span><span class="p">];</span>
</span></code></pre></td></tr></table></div></figure>


<h4>3.特殊场景下的集合类真正的深拷贝:</h4>

<p>如果对于集合类中含有集合类的情况呢？
要实现真正的深拷贝,可以通过序列化(<code>archive</code>)和反序列化(<code>unarchive</code>)该集合类。</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="n">NSArray</span><span class="o">*</span> <span class="n">trueDeepCopyArray</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSKeyedUnarchiver</span> <span class="nl">unarchiveObjectWithData:</span>
</span><span class='line'>                                      <span class="p">[</span><span class="n">NSKeyedArchiver</span> <span class="nl">archivedDataWithRootObject:</span><span class="n">names</span><span class="p">]];</span>
</span><span class='line'>
</span></code></pre></td></tr></table></div></figure>


<p></p>

<p>但是，这种代价相比较而言比较高，慎用!</p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/19/macxia-an-zhuang-nginx-mysql-php/">Mac下配置nginx-mysql-php</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-19T10:10:00+08:00" pubdate data-updated="true">Aug 19<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/19/macxia-an-zhuang-nginx-mysql-php/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>Mac上配置nginx,mysql,php开发环境</p>

<h4>一.安装nginx.</h4>

<p> 1.安装pcre.</p>

<pre><code>brew install pcre
</code></pre>

<p> 2.安装nginx.</p>

<pre><code> brew install nginx
</code></pre>

<p> 如遇见问题，可参考链接:<a href="http://ksnowlv.gitcafe.com/blog/2014/08/18/mac-xia-an-zhuang-nginx/">Mac下安装nginx</a></p>

<h4>二.安装mysql.</h4>

<p>从<a href="http://dev.mysql.com/downloads/mysql/">mysql官网</a>下载Mac版本安装即可。</p>

<h4>三.安装配置php.</h4>

<p><code>Mac</code>内置有<code>php</code>,但是我们选择装新版本的<code>php55</code>.</p>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install php55
==&gt; Installing dependencies for php55: libpng, freetype, gettext, jpeg, unixodbc, homebrew/dupes/zlib, libtool
==&gt; Installing php55 dependency: libpng
....
</code></pre>

<p><code>php55</code>安装完成后,修改<code>nginx</code>配置文件。</p>

<p>在<code>/usr/local/etc/nginx</code>目录中,打开<code>nginx.conf</code>,添加对php的支持。</p>

<p><img src="/images/post/2014-08-19-macxia-an-zhuang-nginx-mysql-php/nginx_php_config.png" alt="image" /></p>

<h4>四.测试php页面。</h4>

<p>1.在<code>/usr/local/Cellar/nginx/1.6.1/html</code>目录下创建页面<code>index.php</code>.
内容为：</p>

<pre><code>&lt;?php phpinfo();?&gt;
</code></pre>

<p>2.在终端启动<code>PHP</code>和<code>nginx</code>服务</p>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$SystemStarter php55-fpm restart
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo nginx -s reload
Password:
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$
</code></pre>

<p>3.在浏览器打开<code>http://localhost:8080/index.php</code>，就可以看到<code>php页面</code>。</p>

<p><img src="/images/post/2014-08-19-macxia-an-zhuang-nginx-mysql-php/php_main_page.png" alt="image" /></p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/18/mac-xia-an-zhuang-nginx/">Mac下安装nginx</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-18T20:08:00+08:00" pubdate data-updated="true">Aug 18<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/18/mac-xia-an-zhuang-nginx/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>Mac下安装nginx,我使用的是Homebrew,Homebrew安装好的情况下。</p>

<h4>1.先安装pcre.</h4>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install pcre
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install pcre
==&gt; Downloading https://downloads.sf.net/project/machomebrew/Bottles/pcre-8.35.mavericks.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/pcre-8.35.mavericks.bottle.tar.gz
==&gt; Pouring pcre-8.35.mavericks.bottle.tar.gz
#忽略该错误是要付出代价的，请看后面!!!!!
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/man1/pcre-config.1
Target /usr/local/share/man/man1/pcre-config.1
already exists. You may want to remove it:
  rm /usr/local/share/man/man1/pcre-config.1
#解决方法之一，注意!!!
To force the link and overwrite all conflicting files:
  brew link --overwrite pcre

To list all files that would be deleted:
  brew link --overwrite --dry-run pcre

Possible conflicting files are:
</code></pre>

<p>静待pcre安装完即可。</p>

<h4>2.安装nginx.</h4>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install nginx
==&gt; Downloading https://downloads.sf.net/project/machomebrew/    Bottles/nginx-1.6.1.mavericks.bottle.tar.gz
</code></pre>

<p> 静待nginx安装完成即可。</p>

<h4>如果安装出错，例如出现</h4>

<pre><code> Error: You must `brew link pcre' before nginx can be installed   
</code></pre>

<p> 参考链接:<a href="http://ksnowlv.gitcafe.com/blog/2014/08/18/you-must-brew-link-pcre-before-nginx-can-be-installed/">http://ksnowlv.gitcafe.com/blog/2014/08/18/you-must-brew-link-pcre-before-nginx-can-be-installed/</a> 解决办法。</p>

<h4>如果解决上述错误会怎么样呢？nginx环境安装不成功呗。</h4>

<p>  在启动nginx时，<code>http://localhost:8080/</code>，页面一直显示<code>404</code>。</p>

<h4>3.启动nginx。</h4>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo nginx
Password:
</code></pre>

<p>输入正确密码后,在浏览器中打开<code>http://localhost:8080/</code>,即可看到<code>nginx欢迎页面</code></p>

<p><img src="/images/post/2014-08-18-mac-xia-an-zhuang-nginx/welcome_nginx.png" alt="image" /></p>

<p>可以使用<code>sudo nginx -s stop</code>关闭<code>nginx</code>服务。</p>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo nginx -s stop
</code></pre>

<h4>4.查看nginx版本信息和help</h4>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$nginx -v
nginx version: nginx/1.6.1

ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$nginx -h
nginx version: nginx/1.6.1
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/Cellar/nginx/1.6.1/)
  -c filename   : set configuration file (default: /usr/local/etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file
</code></pre>

<p>总结:今天尝试把pcre,nginx在Mac上卸载一遍,重新安装时,才发现当时忽略</p>

<pre><code>Error: You must `brew link pcre' before nginx can be installed
</code></pre>

<p>  是多大的灾难,一直是以为配置不对,前前后后检查配置文件&hellip;</p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/18/you-must-brew-link-pcre-before-nginx-can-be-installed/">You Must `brew Link Pcre&#8217; Before Nginx Can Be Installed</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-18T19:53:00+08:00" pubdate data-updated="true">Aug 18<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/18/you-must-brew-link-pcre-before-nginx-can-be-installed/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>在使用Homebrew安装nginx时,会遇见如下错误:</p>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install nginx
Error: You must `brew link pcre' before nginx can be installed
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$
</code></pre>

<p> 可使用命令<code>brew link --overwrite pcre</code>，强制链接并覆盖冲突的文件即可。</p>

<pre><code>ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew link --overwrite pcre
Linking /usr/local/Cellar/pcre/8.35... 133 symlinks created
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install nginx
</code></pre>

<p>如果使用上述命令出错，则找到<code>/usr/local/Cellar/pcre</code>和<code>/usr/local/opt/pcre</code>的<code>pcre</code>目录干掉，重新安装pcre,再强制链接。</p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/17/mac-xia-da-jian-ji-yu-apachede-phpkai-fa-huan-jing/">Mac下搭建基于Apache的PHP开发环境</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-17T20:52:00+08:00" pubdate data-updated="true">Aug 17<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/17/mac-xia-da-jian-ji-yu-apachede-phpkai-fa-huan-jing/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><h4>一.开启Apache服务。</h4>

<pre><code>#输入sudo apachectl start命令,再输入密码
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo apachectl start
Password:

#查看Apache版本信息
ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$sudo apachectl -v
Password:
Server version: Apache/2.2.26 (Unix)
Server built:   Dec 10 2013 22:09:38
</code></pre>

<p>此时在浏览器上输入<code>http://localhost</code>,会出现<code>It works!</code>页面。</p>

<h4>二.启用PHP.</h4>

<p>1.在<code>/etc/apache2/</code>目录下，打开<code>httpd.conf</code>，找到<code>LoadModule php5_module libexec/apache2/libphp5.so</code>,把<code>#</code>去掉，保存即可。</p>

<p><img src="/images/post/2014-08-17-mac-xia-da-jian-ji-yu-apachede-phpkai-fa-huan-jing/use_php.png" alt="image" /></p>

<p>2.复制<code>/Library/WebServer/Documents/index.html.en</code>文件到<code>/Library/WebServer/Documents/</code>目录下，重新命名为<code>index.php</code>
  打开<code>index.php</code>,在<code>It works</code>后面加上<code>&lt;?php phpinfo(); ?&gt;</code></p>

<p>3.重启Apache服务。</p>

<pre><code>sudo apachectl restart
</code></pre>

<p>在浏览器中输入<code>http://localhost/index.php</code>，会出现一个显示php信息的页面.</p>

<p> <img src="/images/post/2014-08-17-mac-xia-da-jian-ji-yu-apachede-phpkai-fa-huan-jing/php_page.png" alt="image" /></p>

<h4>三.配置MySql.</h4>

<p>1.在<a href="http://dev.mysql.com/downloads/mysql/">http://dev.mysql.com/downloads/mysql/</a>下载Mac版。选择<code>Mac OS X 10.8 (x86, 64-bit), DMG Archive</code>安装完即可。</p>

<p>2.在<a href="http://www.phpmyadmin.net/home_page/downloads.php">http://www.phpmyadmin.net/home_page/downloads.php</a>下载<code>phpMyAdmin</code>,选择<code>phpMyAdmin-4.2.7-all-languages.7z</code>下载完成后，解压放进<code>/Library/WebServer/Documents/</code>，重命名为<code>phpmyadmin</code></p>

<p>3.复制<code>/Library/WebServer/Documents/phpmyadmin/config.sample.inc.php</code>到<code>/Library/WebServer/Documents/phpmyadmin</code>目录下， 并命名为<code>config.inc.php</code></p>

<p>4.编辑config.inc.php。</p>

<pre><code>$cfg['Servers']]$i]['host'] = 'localhost';
</code></pre>

<p>修改为:</p>

<pre><code>$cfg['Servers']]$i]['host'] = '127.0.0.1'; 
</code></pre>

<p>如果想要无密码登陆，则将其中的下面语句中的false改成true.</p>

<pre><code>$cfg['Servers'][$i]['AllowNoPassword'] = false
</code></pre>

<p>5、在浏览器中输入<code>http://localhost/phpmyadmin</code>
 输入用户名&#8221;root&#8221;,按上一步的无密码操作即可直接登陆。</p>

<p>  <img src="/images/post/2014-08-17-mac-xia-da-jian-ji-yu-apachede-phpkai-fa-huan-jing/mysql_page.png" alt="image" /></p>

<h4>四.在Mac上使用<code>Sublime Text 2</code>开发PHP即可。</h4>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/17/clean-memory-slash-dirty-memory/">iOS中clean Memory/dirty Memory</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-17T16:45:00+08:00" pubdate data-updated="true">Aug 17<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/17/clean-memory-slash-dirty-memory/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>iOS系统中,有<code>clean memory</code>/<code>dirty memory</code>之分；</p>

<h4>1.<code>clean memory</code>:可以被重新创建的内存块。包含以下三方面：</h4>

<pre><code>1.系统framework
2.应用的二进制执行文件.
3.内存数据映射到文件。
</code></pre>

<h4>当你的App链接一个<code>framewrok</code>,<code>clean memory</code>会增加。绝大多数情况下，只有部分framework的二进制文件是通过物理内存加载的。</h4>

<h4>2.<code>dirty memory</code>:除了<code>clean memory</code>之外所有的内存统称为<code>dirty memory</code>.<code>dirty memory</code>不能由系统重新创建。</h4>

<h4>3.系统有内存压力时，例如内存警告。</h4>

<h4>当有内存压力时，系统将会卸载一些<code>clean memory</code>。当系统需要该clean memory的数据时，系统将会重新创建。</h4>

<h4>但是，有内存压力时，系统不能卸载<code>dirty memory</code>,因为iOS没有内存置换机制，<code>dirty memory</code>经常占有物理内存，当<code>dirty memory</code>达到一个上限，应用就会被&#8221;杀死&#8221;.所有的内存由系统回收。</h4>

<h4>4.如何减少dirty memory呢？例如:</h4>

<pre><code>  1.[NSData dataWithContentsOfMappedFile:]替代内存加载。
  可惜该API现在不推荐使用。
  2.使用[UIImage imageWithContentsOfFile:]替代[UIImage imageNamed]
  3.降低内存占用。
  4.适当的cache.
</code></pre>

<h4>5.如何发现定位dirty memory呢?可以参考<a href="http://liam.flookes.com/wp/2012/05/03/finding-ios-memory/">Finding iOS memory</a></h4>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/16/ios7-dot-1-frameworks/">iOS7.1-Frameworks</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-16T16:15:00+08:00" pubdate data-updated="true">Aug 16<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/08/16/ios7-dot-1-frameworks/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>iOS7.1 Frameworks</p>

<p><img src="/images/post/2014-08-16-ios7-dot-1-frameworks/iOS7-1-Frameworks.png" alt="image" /></p>
</div>
  
  


    </article>
  
  <div class="pagination">
    
      <a class="prev" href="/blog/page/10/">&larr; Older</a>
    
    <a href="/blog/archives">Blog Archives</a>
    
    <a class="next" href="/blog/page/8/">Newer &rarr;</a>
    
  </div>
</div>
<aside class="sidebar">
  
    <section>
  <h1>关于我</h1>
  <p>律威,QQ:309235009 微信:ksnowlv</p>
  <p>手机单机游戏/手机网游封神online/手机阅读/腾讯iOS地图客户端&实时公交&开放API(地图&街景)/iPad/iPhone淘宝客户端及性能优化</p>
  <p>目前在银客做银客/简理财/&#8230;</p>
  <p>能做一点,是一点;不求大成,不求一万年;积少成多,水到渠成!</p>
</section>
<section>
  <h1>最近发布</h1>
  <ul id="recent_posts">
    
      <li class="post">
        <a href="/blog/2017/04/26/android-drawable/">Android drawable</a>
      </li>
    
      <li class="post">
        <a href="/blog/2017/04/22/iOS-xia-shi-yong-ffmpeg/">iOS下使用ffmpeg</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/08/19/ios-you-xian-hou-tai-ren-wu/">iOS有限后台任务</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/08/19/android-xia-jie-ya-suo/">Android下gzip数据流解压缩</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/08/19/facebook-infer-de-shi-yong/">FaceBook-infer的使用</a>
      </li>
    
  </ul>
</section>
<section>
  <h1>分类</h1>
    <ul id="category-list"><li><a href='/blog/categories/android-jie-ya-suo/'>Android-解压缩 (1)</a></li><li><a href='/blog/categories/androidduo-xian-cheng/'>Android多线程 (3)</a></li><li><a href='/blog/categories/androidcha-jian/'>Android插件 (1)</a></li><li><a href='/blog/categories/androidhui-tu-./'>Android绘图。 (1)</a></li><li><a href='/blog/categories/androidwang-luo/'>Android网络 (1)</a></li><li><a href='/blog/categories/git/'>git (6)</a></li><li><a href='/blog/categories/githubbo-ke/'>github博客 (8)</a></li><li><a href='/blog/categories/ios/'>iOS (6)</a></li><li><a href='/blog/categories/ios-block/'>iOS-block (1)</a></li><li><a href='/blog/categories/ios-bug/'>iOS-Bug (2)</a></li><li><a href='/blog/categories/ios-memory/'>iOS-Memory (4)</a></li><li><a href='/blog/categories/ios-push/'>iOS-push (1)</a></li><li><a href='/blog/categories/ios-ui/'>iOS-UI (2)</a></li><li><a href='/blog/categories/ios-you-hua/'>iOS-优化 (1)</a></li><li><a href='/blog/categories/ios-nei-cun/'>iOS-内存 (1)</a></li><li><a href='/blog/categories/ios-ji-chu/'>iOS-基础 (3)</a></li><li><a href='/blog/categories/ios-duo-xian-cheng/'>iOS-多线程 (3)</a></li><li><a href='/blog/categories/ios-cun-chu/'>iOS-存储 (1)</a></li><li><a href='/blog/categories/ios-an-quan/'>iOS-安全 (1)</a></li><li><a href='/blog/categories/ios-wang-luo/'>iOS-网络 (13)</a></li><li><a href='/blog/categories/ios-jie-ya-suo/'>iOS-解压缩 (1)</a></li><li><a href='/blog/categories/ios-she-ji-mo-shi/'>iOS-设计模式 (1)</a></li><li><a href='/blog/categories/ios-diao-shi/'>iOS-调试 (1)</a></li><li><a href='/blog/categories/iosyou-hua/'>iOS优化 (1)</a></li><li><a href='/blog/categories/iosji-chu/'>iOS基础 (2)</a></li><li><a href='/blog/categories/iosyin-pin/'>iOS音频 (1)</a></li><li><a href='/blog/categories/mac/'>Mac (4)</a></li><li><a href='/blog/categories/mac-duo-xian-cheng/'>Mac-多线程 (1)</a></li><li><a href='/blog/categories/nginx/'>nginx (3)</a></li><li><a href='/blog/categories/php/'>php (3)</a></li><li><a href='/blog/categories/python/'>python (12)</a></li><li><a href='/blog/categories/swift/'>swift (11)</a></li><li><a href='/blog/categories/uml/'>UML (8)</a></li><li><a href='/blog/categories/xcode/'>Xcode (11)</a></li><li><a href='/blog/categories/chan-pin-she-ji/'>产品设计 (2)</a></li><li><a href='/blog/categories/gong-ju/'>工具 (2)</a></li><li><a href='/blog/categories/shu-ju-ku/'>数据库 (2)</a></li><li><a href='/blog/categories/sheng-huo-pian-duan/'>生活片段 (10)</a></li><li><a href='/blog/categories/zhi-ye-sheng-ya/'>职业生涯 (7)</a></li><li><a href='/blog/categories/du-shu/'>读书 (2)</a></li></ul>
</section>
<section>
  <h1>外部链接</h1>
    <ul id="外部链接">
    	<li><a href="https://developer.apple.com">苹果开发者中心</a> </li>
    	<li><a href="http://stackoverflow.com/questions/tagged/ios">stackoverflow</a></li>
    	<li><a href="http://ksnowlv.blog.163.com/blog/#m=0">ksnowlv网易博客</a></li>
	</ul>
</section>

  
</aside>

    </div>
  </div>
  <footer role="contentinfo"><p>
  Copyright &copy; 2017 - 律威 -
  <span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>

  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1253538110'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "v1.cnzz.com/z_stat.php%3Fid%3D1253538110%26online%3D1' type='text/javascript'%3E%3C/script%3E"));</script>

  <script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F4c1727a94ea20751730e8a556dbdbf82' type='text/javascript'%3E%3C/script%3E"));
</script>

</p>



</footer>
  

<script type="text/javascript">
      var disqus_shortname = 'ksnowlv';
      
        
        var disqus_script = 'count.js';
      
    (function () {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    }());
</script>








</body>
</html>
